"""
    Controller for students transfers table.
"""

from mnemoply import model
from mnemoply.controllers.lookup import LookupController, TableCol, TableLookupDataSource
from mnemoply.controllers.crud import CRUDController
from mnemoply.utils import LocalMenuItem

class TransferController(LookupController, CRUDController):
    model_object = model.Transfer
    lookup_columns = [
        TableCol(name='date', caption=_('Date')),
        TableCol(name='student', caption=_('Student')),
        TableCol(name='group_from', caption=_('Group from')),
        TableCol(name='group_to', caption=_('Group to')),
        TableCol(name='reason', caption=_('D:Reason'), hidden=True),
        TableCol(name='is_self_wish', caption=_('D:IsSelfWish'), hidden=True),
        TableCol(name='order_id', caption=_('Order'), hidden=True),
        TableCol(name='planned', caption=_('planned'), hidden=True),
        TableCol(name='comment', caption=_('Comment'), hidden=True),
        ]
    view_fields = [
        'date', 'studentID',
        'groupFromID', 'groupToID',
        'orderID',
        'planned',
        'comment',
        ]

    def __init__(self):
        LookupController.__init__(self,
            data_source=TableLookupDataSource('transfer_lookup'),
            columns=self.lookup_columns,
            title=self.model_object.model_title,
        )
        CRUDController.__init__(self, model_object=self.model_object)
        self.object_local_menu = [LocalMenuItem(caption=_('List'), href='../list')]
        self.local_menu = []

exposed = TransferController()
